import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    shopCart:[]
  },
  mutations: {
    appShopcar(state,obj){
      let a=0;
      state.shopCart.map(item=>{
        if(item.id==obj.id){
          item.count++
          a++
        }
      })
      if(a==0){
        state.shopCart.push(obj)
      }
      // console.log(state.shopCart)
    },
    delShopCar(state,arr){
      state.shopCart=arr
    }
  },
  actions: {
    
  },
  modules: {
  }
})
